package com.xiyi.shouxin.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource(value = "classpath:/wx.properties")
public class WXConfig {

    private static String APPID = "";

    private static String SECRET = "";

    // 网页扫码登陆重定向地址
    private static String REDIRECTURL = "";

    // 微信获取access_token的地址
    private static String ACCESSTOKENURL = "";

    // 微信刷新access_token的地址
    private static String REFRESHTOKENURL = "";

    // 微信检验授权凭证access_token的地址
    private static String CHECKTOKENURL = "";

    // 获取微信用户个人信息的地址
    private static String USERINFOURL = "";

    // 微信小程序登录的地址
    private static String CODE2SESSION = "";

    @Value(value = "${wxconfig.appId}")
    private void initAppId(String APPID) {
        WXConfig.APPID = APPID;
    }

    public static String getAppId() {
        return WXConfig.APPID;
    }

    @Value(value = "${wxconfig.secret}")
    private void initSecret(String SECRET) {
        WXConfig.SECRET = SECRET;
    }

    public static String getSecret() {
        return WXConfig.SECRET;
    }

    @Value(value = "${wxconfig.redirectUri}")
    private void initRedirectUrl(String REDIRECTURL) {
        WXConfig.REDIRECTURL = REDIRECTURL;
    }

    public static String getRedirectUrl() {
        return WXConfig.REDIRECTURL;
    }

    @Value(value = "${wxconfig.accessTokenUrl}")
    private void initAccessTokenUrl(String ACCESSTOKENURL) {
        WXConfig.ACCESSTOKENURL = ACCESSTOKENURL;
    }

    public static String getAccessTokenUrl() {
        return WXConfig.ACCESSTOKENURL;
    }

    @Value(value = "${wxconfig.refreshTokenUrl}")
    private void initRefreshTokenUrl(String REFRESHTOKENURL) {
        WXConfig.REFRESHTOKENURL = REFRESHTOKENURL;
    }

    public static String getRefreshTokenUrl() {
        return WXConfig.REFRESHTOKENURL;
    }

    @Value(value = "${wxconfig.checkTokenUrl}")
    private void initCheckTokenUrl(String CHECKTOKENURL) {
        WXConfig.CHECKTOKENURL = CHECKTOKENURL;
    }

    public static String getCheckTokenUrl() {
        return WXConfig.CHECKTOKENURL;
    }

    @Value(value = "${wxconfig.userInfoUrl}")
    private void initUserInfoUrl(String USERINFOURL) {
        WXConfig.USERINFOURL = USERINFOURL;
    }

    public static String getUserInfoUrl() {
        return WXConfig.USERINFOURL;
    }

    @Value(value = "${wxconfig.code2Session}")
    private void initCode2Session(String CODE2SESSION) {
        WXConfig.CODE2SESSION = CODE2SESSION;
    }

    public static String getCode2Session() {
        return WXConfig.CODE2SESSION;
    }
}
